package com.pinda.controller;


import com.pinda.authorization.entity.Resources;
import com.pinda.commonutils.Result;
import com.pinda.commonutils.StatusCode;
import com.pinda.service.ResourcesService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 资源 前端控制器
 * </p>
 *
 * @author 黄杰
 * @since 2023-06-13
 */
@RestController
@RequestMapping("/resources")
public class ResourcesController {
    @Resource
    private ResourcesService resourcesService;

    /**
     * TODO 根据用户id查询具有的权限资源列表
     *
     * @param userId
     * @return List<PdAuthResource>
     */
    @RequestMapping("findUserByIdResource/{id}")
    List<String> findUserByIdResource(@PathVariable("id") String userId){
        return this.resourcesService.findUserByIdResourceService(userId);
    }

    /**
     * TODO 根据用户id查询具有的权限资源列表
     * @param userId
     * @return List<Resources>
     */
    @RequestMapping("findUserByIdResourceAll/{id}")
    Result<List<Resources>> findUserByIdResourceAll(@PathVariable("id") String userId){
        return new Result<List<Resources>>(true, StatusCode.OK,"查询成功",this.resourcesService.findUserByIdResourceAllService(userId));
    }
}
